<script type="text/javascript">
	function check(){
		var check = document.frmAddEmps.chkPERSONNELIDNO,
		sChecked = "",
		sUnChecked = ""
		if (check[0]){
			for (i = 0; i < check.length; ++ i){
				if (check[i].checked){
					sChecked = sChecked + check[i].value + ","
				} else {
					sUnChecked = sUnChecked + check[i].value + ","
				}
			}
		} else {
			if (check.checked){
				sChecked = sChecked + check.value + ","
			} else {
				sUnChecked = sUnChecked + check.value + ","
			}
		}
		document.frmAddEmps.hidCheck.value = sChecked;
		document.frmAddEmps.hidUnCheck.value = sUnChecked;


		return true;
	}
	function checkMe(lblLbl) {
		var theLbl = document.getElementById("id" + lblLbl);
		var theId = eval("document.frmAddEmps.chk" + lblLbl);
		if (theId[0]){
			for (i = 0; i < theId.length; ++ i) {
				theId[i].checked = theLbl.checked;
			}
		} else {
			theId.checked = theLbl.checked;
		}
	}
</script>
<CFQUERY NAME="getUSERFILTERIDs" DATASOURCE="#client.company_dsn#">
	SELECT USERFILTERID, ISDEFAULT, USERFILTERTYPE FROM ECRGUSERFILTER
	WHERE FORMCODE = '#sID#'
		AND ISDEFAULT='Y'
</CFQUERY>
<CFSET sBuffFilter = "">
<CFSET sBuffFilterAll = "">
<CFIF getUSERFILTERIDs.recordCount GT 0>
	<CFLOOP QUERY = "getUSERFILTERIDs">
			<!---{{{ Filter will use specific filter --->
			<CFSET filterType = getUSERFILTERIDs.USERFILTERTYPE>
			<CFIF filterType EQ "USERDEFINED">
				<!---{{{ USERDEFINED--->
				<CFQUERY NAME="qryCRGUSERFILTERCONDITION" DATASOURCE="#client.company_dsn#">
					SELECT PRIORITYNO, ALIAS, SOURCEFIELD, OPERATOR, VALUEORALIAS,
							JOININGFIELD, JOININGOPERATOR, GROUPSTART, GROUPEND, '0' AS CONDITION_TAG
					FROM ECRGUSERFILTERCONDITION
					WHERE USERFILTERID = '#getUSERFILTERIDs.USERFILTERID#'
					ORDER BY USERFILTERID, PRIORITYNO <!--- Please don't change order by,
						changing the order by will result to a logical error in program --->
				</CFQUERY>
				<!---}}}--->
			<CFELSE>
				<!---{{{ GROUP--->
				<CFQUERY NAME="qryCRGUSERFILTERCONDITION" DATASOURCE="#client.company_dsn#">
					SELECT USERFILTERFIELD,TABLEFILTERFIELD,GROUPFILTERTYPE
					FROM ECRGUSERFILTERGROUP
					WHERE USERFILTERID = '#getUSERFILTERIDs.USERFILTERID#'
				</CFQUERY>
				<!---}}}--->
			</CFIF>
			<CFSET perUserExist = true>
			<CFSET passed = true>
			<CFINCLUDE TEMPLATE="userfilterfunc_genfilter.cfm">
			<!---}}}--->
	</CFLOOP>
	<!---}}}--->
</CFIF>
<CFQUERY NAME="QUERYVIEW" DATASOURCE="#client.company_dsn#">
	SELECT
		PERSONNELIDNO, LASTNAME, FIRSTNAME, MIDDLENAME,EMPLOYMENTSTATUS
	FROM CMFPA
	<!--- Modified by Badz to avoid displaying employees with null EMPLOYMENTSTATUS --->
	WHERE  EMPLOYMENTSTATUS <> 'SEPARATED' AND EMPLOYMENTSTATUS <> ''
	<CFIF sBuffFilterAll NEQ "">
		 AND #PRESERVESINGLEQUOTES(sBuffFilterAll)#
	</CFIF>
	<CFIF IsDefined("Form.edtValFilter") AND #Form.edtValFilter# NEQ "">
		AND #Form.cmbSort# LIKE '%#Form.edtValFilter#%'
	</CFIF>
	<CFIF IsDefined("form.cmbSort")>
		ORDER BY #form.cmbSort# <CFIF IsDefined("form.ascdesc")>#form.ascdesc#</CFIF>
	<CFELSE>
		ORDER BY LASTNAME<!--- BADZ 09052008 --->
	</CFIF>

</CFQUERY>

<CFSET checkList = "">

<CFIF isDefined("form.hidCheckList")>
	<CFSET checkList = "#form.hidCheckList#">
	<CFLOOP INDEX="i" LIST="#form.hidUnCheck#">
		<CFIF listFind(checkList,i) NEQ 0>
			<CFSET checkList = listDeleteAt(checkList,listFind(checkList,i))>
		</CFIF>
	</CFLOOP>

	<CFLOOP INDEX="i" LIST="#form.hidCheck#">
		<CFIF listFind(checkList,i) EQ 0>
			<CFSET checkList = listAppend(checkList,i)>
		</CFIF>
	</CFLOOP>
</CFIF>

<CFIF isDefined("form.hidCheck")>
	<CFSET temp = form.hidCheck>
<CFELSE>
	<CFSET temp = "">
</CFIF>
<CFIF isDefined("form.hidUnCheck")>
	<CFSET Untemp = form.hidUnCheck>
<CFELSE>
	<CFSET Untemp = "">
</CFIF>

<CFSET lstAddtnlButton="btnAddEmp~Add~Add,btnBackAdd~Back~Back">
<!--- BADZ 09052008 --->
<CFSET lstOrder="Last Name~LASTNAME~ftString,Personnel Id No~PERSONNELIDNO~ftString,First Name~FIRSTNAME~ftString,Middle Name~MIDDLENAME~ftString,Section~SECTIONCODE~ftString,Position~POSITIONCODE~ftString,Employment Status~EMPLOYMENTSTATUS~ftString">
<CFSET frmname="frmAddEmps">
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Select Employees">
<CFOUTPUT>
	<CFSET act = URLEncodedFormat(encrypt("addemployees",client.ek))>
	
	<FORM ACTION="index.cfm?id=#sIDUrlEnc#&wsnum=#wsIDnumEnc#" METHOD="POST" NAME="frmAddEmps" onSubmit="javascript: check()">
	<INPUT TYPE="Hidden" NAME="hidCheckList" value="#checkList#">
	<INPUT TYPE="Hidden" NAME="hidCheck" value="">
	<INPUT TYPE="Hidden" NAME="hidUnCheck" value="">
	<INPUT TYPE="Hidden" NAME="hidemployee" value="">


	<CFINCLUDE template="#client.common_path#/toolbar.cfm">
	<CFIF isDefined("form.refresh")>
		<CFSET checkList = "">
		<CFSET nStartrow = 1>
	</CFIF>
</CFOUTPUT>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 WIDTH="100%">
	<CFOUTPUT>
		<TR BGCOLOR="#client.color_tblhead#">
			<TD HEIGHT=18><CFIF QueryView.recordcount GT 0><INPUT TYPE="checkbox" NAME="lblPERSONNELIDNO" id="idPERSONNELIDNO" label="" onClick="javascript:checkMe('PERSONNELIDNO')"></CFIF></TD>
			<TD CLASS="boldwhite">Personnel ID No.</TD>
			<TD CLASS="boldwhite">Last Name</TD>
			<TD CLASS="boldwhite">First Name</TD>
			<TD CLASS="boldwhite">Middle Name</TD>
			<TD CLASS="boldwhite">Employment Status</TD>
		</TR>
	</CFOUTPUT>
	<CFIF QueryView.recordcount GT 0>
		<CFOUTPUT QUERY="QueryView" StartRow="#nStartrow#" MAXROWS="#Evaluate(nEndrow - nStartrow + 1)#">
		<TR BGCOLOR="#IIf(CurrentRow Mod 2, "client.color_tblset2", "client.color_tblset1")#" VALIGN="top">
			<TD>
				<INPUT TYPE="checkbox" NAME="chkPERSONNELIDNO" VALUE="#PERSONNELIDNO#" <CFIF listFind(checkList, PERSONNELIDNO) NEQ 0>CHECKED</CFIF>>
			</TD>
			<TD>#PERSONNELIDNO#</TD>
			<TD>#LASTNAME#</TD>
			<TD>#FIRSTNAME#</TD>
			<TD>#MIDDLENAME#</TD>
			<TD>#EMPLOYMENTSTATUS#</TD>
		</TR>
		</CFOUTPUT>
	<CFELSE>
		<tr><td class="bold" WIDTH=250>No records found in the current filter.</td></tr>
	</CFIF>
	<CFOUTPUT>
		<TR BGCOLOR="#client.color_tblfoot#">
			<TD COLSPAN=8	CLASS="boldwhite" HEIGHT=18>Records: #nStartrow# - #nEndRow# of #QueryView.RecordCount#</TD>
		</TR>
	</CFOUTPUT>
</TABLE>
</FORM>
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
